clear
clc
x = 0 : 255;
y = zeros(1,length(x));
%y = sin(4*x)+sin(25*x);
y(x<=31|x>=127)=1;
%y = 1;
figure,plot(x,y);axis([0 255 -4 4]);
W = mywigner(y');
% Ts = 1;
% SamplingFreq = 1/Ts;
% N = length(x)/2;
% FreqAxis = linspace(0,(N-1)/2,N/2)./(N/2);
% F = fft(y,N);
% F(1)=[];
% figure,plot(FreqAxis,abs(F(1:N/2)));
% 
% W = zeros(length(FreqAxis),length(x));
% 
% for mu = 1 : size(W,1)
%     for x1 = 1 : size(W,2)
%         total = 0;
%         for xprime = 1 : length(x)
%             if (x1+xprime < length(x) && x1-xprime > 1)
%                 total = total + ((x(x1)+x(xprime))*(x(x1)-x(xprime)))*exp(-j*2*pi*x(xprime)*mu);
%             end
%             W(mu,x1)=total;
%         end
%     end
% end

figure,surf(abs(W));